package com.chinatelecom.auth.mockmvc;

import com.chinatelecom.auth.mockmvc.inter.BuilderInterface;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by liujinyao on 2017/7/28.
 */
public class AuthHttpRequest {

    public String method;
    public String uri;
    public Map<String,String> headers;
    public String content;

    public AuthHttpRequest(){}

    public AuthHttpRequest(Builder builder){
        String meth = builder.method;
        this.method = meth==null?"post":meth;
        this.uri = builder.uri;
        this.headers = builder.headers;
        this.content = builder.content;
    }

    public static class Builder implements BuilderInterface<AuthHttpRequest>{

        private String method;
        private String uri;
        private Map<String,String> headers;
        private String content;

        @Override
        public AuthHttpRequest build() {
            return new AuthHttpRequest(this);
        }

        public Builder method(String method){
            this.method = method;
            return this;
        }

        public Builder uri(String uri){
            this.uri = uri;
            return this;
        }

        public Builder header(String key, String value){
            if(headers==null){
                headers = new HashMap<>();
            }
            headers.put(key,value);
            return this;
        }

        public Builder content(String content){
            this.content = content;
            return this;
        }
    }
}
